/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    $('#StaffCalendar').fullCalendar({
//			header : { right: false, left: title},
        month: m,
        weekends: false,
        editable: true,
        selectable: true,
        disableDragging: true,
        events: "rosters/feed",
        //Fullcalendar form

        dayClick: function(startDate, endDate, allDay, jsEvent, view) {

            //Show date
            var date = new Date(startDate);
            var startyear = date.getFullYear();
            var startday = date.getDate();
            var startmonth = date.getMonth() + 1;
            var fulldate = startday + "/" + startmonth + "/" + startyear;
            var cakedate = startyear + "-" + startmonth + "-" + startday;
            document.getElementById('prefDate').value = fulldate;
            document.getElementById('hiddendate').value = cakedate;

            var myDate = new Date();


            if (date < myDate) {
                //TRUE Clicked date smaller than today + daysToadd
                alert("You cannot add your availability on this day!");


            }
            else
            {
                //Reset
                document.getElementById("staffForm").reset();



                artday = date.getDate();
                var startmonth = date.getMonth() + 1;
                var fulldate = startday + "/" + startmonth + "/" + startyear;
                var cakedate = startyear + "-" + startmonth + "-" + startday;
                document.getElementById('prefDate').value = fulldate;
                document.getElementById('hiddendate').value = cakedate;


                //var popup = document.getElementById("staffCalendarForm");
                //popup.style.display = 'block';
                $('#staffCalendarForm').bPopup();


                eventColor: '#378006';
            }
        }
    });


});

